On Notification Added Event
Emitted whenever the SDK receives a new notification from the agency. Notifications represent high-level business messages (e.g. new credential offers, proof requests) rather than low-level transport frames.
-
Purpose: Inform your application that a new user-facing notification has arrived so you can persist it, show an in-app banner or system notification, and update any UI lists.
-
Functionality: The handler receives a
NotificationModel
object containing metadata about the notification, including:id
(string) – Unique notification identifier.type
(enum) – Notification category (e.g.CREDENTIAL_OFFER
,PRESENTATION_REQUEST
).timestamp
(number) – Unix epoch in milliseconds when the notification was generated.payload
(object) – Encoded message details (contents vary by type).
-
Usage: Implement this in your
EventHandlers
and decide how your app surfaces notifications:- Save to local DB or Redux for offline access.
- Display a toast/snackbar or push a local notification.
- Navigate user to a specific screen when tapped.
-
Example:
import { NotificationModel } from '@one37id/mobile-js-sdk';
import { eventEmitter } from '../services';
const handlers: EventHandlers = {
onNotificationAdded: async (model: NotificationModel) => {
console.debug('New SDK notification:', model);
// 1) persist
await notificationService.save(model);
// 2) UI toast
Toast.show({
title: 'New request',
message: 'A new Notification arrived',
});
// 3) update badge & emit event
eventEmitter.emit('notificationAdded', model);
},
};